How do you use 2D and 3D lights in Unity simultaneously?
I have a game where there are 3D asteroids floating around but everything else is 2D and I want to use both 2 and 3D lighting. I made the engine use the 2D renderer asset but now my 3D models are not light, Is there a way to light both at the same time? thanks for any help on this matter.
Answer by jimmiewalker653 · Oct 10, 2020 at 11:08 AM
@YOYBROYy You'll need 2 cameras for this and you'll need to get the Light Weight Render Pipeline. Once you've setup your Render pipeline, you can add both renders to the pipeline you've created. Next, you'll need two cameras. Camera "A" will render all of your sprites and Camera "B" will render your 3D assets. Camera "A" will need to be an overlay camera and Camera "B" will need to be your base camera. Once you've setup everything up, simply hit the plus button on the camera in the section for "Stack", then add your overlay camera to it. You should now have both 3D and 2D lights interacting with 3D objects and Sprites.
Answer by MTTHKL · Nov 12, 2021 at 04:51 PM
@YOYBROYy I know you asked this more than two years ago, but did you solve this issue? I'm facing exactly same issue - using 2D renderer in URP as its 2D game, but I'd like to render some rotating 3D objects that receive light.
@jimmiewalker653 I tried to follow the steps you mentioned, but it didn't work. Two cameras - OVERLAY camera to render sprites, BASE camera to render 3D objects. OVERLAY camera is added to the stack of BASE camera. I tried to use normal non-2D shaders with the 3D object's material but it didn't work, either the object has receive flat light or not at all (rendered black). Are there some additional steps to do this?
If I want to render 3D objects affected by lights, can I use the same 2D renderer with the BASE camera?
Thanks.
Your answer
Follow this Question
Related Questions
Unity 2D - Material for light 2 Answers
How to use Shadow Caster 2D with Tilemap? 0 Answers
Using two cameras to blend regular 2D orthographic with 3D isometric orthographic elements 0 Answers
Make a 3D Object look like hes facing a point in an 2D space 0 Answers
Issue with simulating cloth in Unity 2D 0 Answers