![]() ![]() if this object is actually the focused one currentlyĪs said I don't know exactly what your VR setup looks like. in the future you should maybe check first So this object will be rendered on top of the image without any blur effect!įor demonstration I just added this simple script to every cube object in order to enable focus on mouse enter and disable it on mouse exit: using UnityEngine This will allow you to focus a certain GameObject on runtime by changing its layer to the Focused layer we added, the only one that is rendered by the FocusCamera. ![]() If (currentlyFocused) currentlyFocused.layer =previousLayer On disable make sure to reset the current object and PostProcessingVolume for not wasting rendering resources if no object is focused disable the FocusCamera If (currentlyFocused) currentlyFocused.layer = previousLayer ĬurrentlyFocused.layer = LayerMask.NameToLayer(FocusedLayer) if something else was focused before reset it enables this camera and the postProcessingVolume which is the child ![]() Public class FocusSwitcher : MonoBehaviour Now everything should be blurred in your scene!Īlmost ready to go! Now Disable the FocusCamera and add this script to it using UnityEngine Now go to the MainCamera and, a component PostProcessingLayer and set the Layer to our added layer PostProcessing Until now nothing has really changed in your scene. In your case you want to overwrite the Focus Distance so check the box on the left and set a value close to the camera like e.g. Set its Layer to the added PostProcessingĮnable Is Global so the distance to the volume doesn't matter and add a new profile by hitting new → Unity → Depth of field RightClick on FocusCamera → 3D Object → Post Processing Volume I would add it as child to the FocusCamera! Why? - Because this way it is automatically disabled together with the FocusCamera! Make sure to remove the AudioListener component.įinally add a new PostProcessingVolume to the scene.Depth : Anything higher than the MainCamera so this camera is rendered on top of it.If you set it to Depth Only the focused object will always be rendered on top of everything, even if it is actually behind other objects in 3D space. It should have all the settings equal to the MainCamera except: RightClick on MainCamera &rightarrow Camera This way it is automatically moved along with the main Camera. Make sure the MainCamera doesn't render the two added Layers → remove them from the Culling MaskĪdd a new Camera FocusCamera as child to the existing MainCamera.If there should be two of them in your project setup just repeat the same steps for the second camera. Afaik it makes no difference whether you are in VR or not, usually you have one MainCamera that is moved along with your headset. Now first of all go to the Layer settings ( Layers → Edit Layers)Īnd add two additional Layers: e.g. Make sure to be in the All Packages view, search for post, find the Post Processing package and hit Install Though your question is a bit broad I took some time to show you how it can be done.įirst of all you will need to import the Post Processing package via the PackageManager ![]()
0 Comments
Leave a Reply. |
AuthorWrite something about yourself. No need to be fancy, just an overview. ArchivesCategories |