Search Unity

Question How do I get lighting on just my minimap camera in URP?

Discussion in 'Universal Render Pipeline' started by Mr_Cobalt124, Feb 23, 2023.

  1. Mr_Cobalt124

    Mr_Cobalt124

    Joined:
    Jan 15, 2018
    Posts:
    3
    Hello, I've recently moved my project to URP from the builtin render pipeline. I had minimap before that was lit by having one light that got toggled off every time there was a render on a camera that wasnt the minimap camera. So, every frame, only the minimap camera would render the light. Unfortunately, this was already buggy in the builtin pipeline, but in URP it just doesn't work, so now I'm looking for a good way to light my minimap in URP as well. I've tried using render objects and an unlit material, but that doesn't work, and I've tried using https://github.com/Cyanilux/URP_BlitRenderFeature to brighten the image with a shader. Using Blit, I can make the image brighter, but it looses all of its detail, as my scene is so dark that no color detail will render on the camera, regardless of how much you try to multiply the colors.

    So my question is, what is the best way in URP to make my minimap bright? Does it involve more hacky light toggling? Or is there a good way to just have lighting on one camera?
     
  2. SF_FrankvHoof

    SF_FrankvHoof

    Joined:
    Apr 1, 2022
    Posts:
    780
  3. Mr_Cobalt124

    Mr_Cobalt124

    Joined:
    Jan 15, 2018
    Posts:
    3
    "A GameObject will only be illuminated by a light if that light's cullingMask/ includes the layer chosen for the GameObject"
    This isn't what I'm looking for. I want every one of the objects to be lit, but I want the light to only render on the minimap camera. Thanks for the response though. And yeah I agree it is painful I've been trying to light my minimap for 2 or 3 days now
     
  4. niwhocug

    niwhocug

    Joined:
    Jan 29, 2024
    Posts:
    4
    come across the same satuation. for urp, the solution from reddit:RenderPipelineManager and using the beginCameraRendering and endCameraRendering events to activate/deactivate certain lights, of the camera shouldn't be able to see it.
    my case for example, minimapCamera turn on global light then turn off. it does work
    Code (CSharp):
    1.  
    2. public class CameraLight : MonoBehaviour
    3. {
    4.     [SerializeField] private Camera _camera;
    5.     [SerializeField] private Light2D _globalLight;
    6.  
    7.     void OnEnable()
    8.     {
    9.         RenderPipelineManager.beginCameraRendering += OnBeginCameraRendering;
    10.         RenderPipelineManager.endCameraRendering += OnEndCameraRendering;
    11.     }
    12.  
    13.     void OnDisable()
    14.     {
    15.         RenderPipelineManager.beginCameraRendering -= OnBeginCameraRendering;
    16.         RenderPipelineManager.endCameraRendering -= OnEndCameraRendering;
    17.     }
    18.  
    19.     void OnBeginCameraRendering(ScriptableRenderContext context, Camera cam)
    20.     {
    21.         if (cam == _camera)
    22.         {
    23.             _globalLight.enabled = true;
    24.         }
    25.     }
    26.  
    27.     void OnEndCameraRendering(ScriptableRenderContext context, Camera cam)
    28.     {
    29.         if (cam == _camera)
    30.         {
    31.             _globalLight.enabled = false;
    32.         }
    33.     }
    34. }
    35.  
    a day passed, hope helpful for others searching for same problem