My question is, I have 2 viewports, one I want to be day view which is currently working.
The other is a night view, I am currently using a colour correction and noise filter to ‘simulate’ night vision on the 2nd viewport.
What I would really like to do is have one viewport in ‘day’ view and the other using the a lighting setup for ‘night’ view.
Is this possible with the layer system? Every time I tried to switch the lights to different layers, it didn’t change anything in the scene. (both cameras were not affected)
You can do this with layers and light.cullingMask property.
Go to Edit -> Project Settings -> Tags
Click on the right side of the User Layer 8, and type in "night".
Click on the right side of the User Layer 9, and type in "day".
Select all objects that you want to be lit by night light, and put them in Layer night (by clicking on Layer drop down in inspector and selecting night).
Select all objects that you want to be lit by day light, and put them in Layer day (by clicking on Layer dropdown in inspector and selecting day).
Make two new tags - nightLights and dayLights
Select all day lights and Tag them in inspector dayLights, all night lights shoud be tagged nightLights.
add this script to your day camera:
function Start(){
dayLightsTagged = GameObject.FindGameObjectsWithTag("dayLights");
for (var dayLight:GameObject in dayLightsTagged){
dayLight.light.cullingMask = 1 <<9;
}
}
add this one you your night camera:
function Start(){
nightLightsTagged = GameObject.FindGameObjectsWithTag("nightLights");
for (var nightLight:GameObject in nightLightsTagged){
nightLight.light.cullingMask = 1 <<8;
}
}
As you can see in both scripts we are finding all object with appropriate tags and assigning it to a var. Then we iterate through all of the objects and affecting cullingMask for every light to lit only objects in particular layers.
what you could do is make a script which will enable all “Day lights” if DayLightCamera is on, and disable all “Night lights” if NightLightCamera is off and vice verse like this:
// attach this to DayLightCamera, and duplicate of the script script to NightLightCamera, only put NightLightNames
function Start(){
if(gameObject.camera.enabled){
GameObject.Find("lightDay").active = true;//enabling light, add more day lights here
}else GameObject.Find("lightDay").active = false;// disabling lights here
}