Life gets weirder for me. Ok, I wanted to have some controllable light (as in aka I want pitch black and a sun that rotates around the terrain) I can’t find the sun control for the default light will find that later, but in the mean time I added a second light source and turned on sun glare. Well the second light has no glare only the default light source has glare and the second light should have the glare but only the default sun has glare. I want to move the sun on a timer and I want the second light source to have glare (aka multiple suns around the planet)
Here is the only thing I got so far, as you can see only 1 glare, if I move the camera and face the second light source, no glare. I am pretty sure I remember where the default light setting is, but in the mean time how to I add halo to the current light source as a secondary halo? Make it show on top of that.
I forgot to mention the default light source is WHITE the secondary light source is YELLOW, in this scene you can see the default light source is YELLOW and the secondary light source is also YELLOW. When I add a new light source the default took on its properties, I can add a screen shot of my project settings to show the default light should not be yellow if you like.
Doc, that sun with flare you are seeing is after I added a light source which is not on the horizon. The sun is actually in the sky, off the top of the image. The sun with the flare is the result of me setting flare on with sun attached to the new light source.
Here give this a try and see what results you get. Create a terrain, standard size, use dirt as the texture for the terrain, rumble it up some. Ok, now add in a skymap, one of the default like ‘sunset’ is fine. Ok, now go into the settings and change the ambient light to black. This will make the terrain black (aka trying to represent full darkness), now, add a secondary light source, place it at 1000,1000,1000, this should be sufficient. Now, change the light source to directtional (or point) and up its intensity to 8 from 1. No difference in the base terrain light. Change the distance to 2000, still no change on my end.Play around with the light settings to see if you can get the terrain to be fully lighted from the secondary source (other than the built in default light that I want turned off completely since I can’t control its orientation or location)
Basically have the light that you just added try to light up the terrain that you have with an ambient black. This in ‘theory’ should be the solution to turning off the ambient light and allowing you full control over the light source. I can’t get it to work on my end.
Directional lights are infinite. It doesnt matter where they are placed in the scene. Its only their rotation that makes the difference in lighting and when lensflares are shown.
When using a point light be sure to increase the range, when you want it to light the whole terrain. A Point light has no rotation effect. Light is only changed, when moving it arround, flares are shown all the time.
As Halos are based on the distance the light travells, directional lights have NO correct halo because it would be endless. Setting a halo to a point light would mess up your scene too, because, you would have to set the range of the point light far enough to light your whole scene… your halo would be that big too.
Now for the conclusion
Use a script to move your directional lights around your scene like suns would do. Be sure to point the directional lights z-axis toward the scene all the time in order to get a correct lighting and to see lensflare effects (You can have multiple lensflares at the same time, its no problem).
Create a Sun (Particle, Sphere-Model, whatever you want) and let it travel with the lightsource for a more convincing effect.
If you only need the lensflares (no sun models) then it would be enough to simply rotate your directional lights anywhere in the scene. Moving them around will have no effect at all. The above stated movement will only be neccessary to control the fake sun models position in a correct context to the incoming light.
Lights in a realtime 3D engine work different from those in 3D Render Applications. Consult the docs for more information about how lights work in Unity.
Thanks for the pointers, however, it doesn’t solve the underlying problem. No way to turn off the default light that has the diffusion on it. Which means the scene is always lit. Nothing in the documentation that I have found to kill the default light source that has diffusion attached to it. If you try what I suggested about creating a terrain, give it a texture turn diffusion to black, then create a point light to point at the terrain placing the light at 1000,1000,1000, give it a value of 8 for its intensity, a range of 2000 which is beyond the terrain by an additional 1000, an angle of 179, constantly point the cone to the terrain, the black area of the terrain made by the diffusion doesn’t get lit.
Consulting the documentation is a great thing but, when this is a problem the documentation doesn’t say “here is how you disable the default light which has the diffusion attached to it”, if it did, would be no need to start this thread
Thanks again for the pointers, still in dire need to kill the default light source with diffusion attached to it.
That is not correct. If in the scene view you click the lightbulb icon, then the scene view will use the in-game lights for lighting. No additional hidden lights will be there at all. No diffusion either (whatever that means :)).
I think you see a separate issue here. Point lights currently don’t work on terrain; if you have one without a layer mask to exclude terrain from it, then it will illuminate the terrain incorrectly (no matter how far away you place it; and it won’t illuminate it like a point light should). Right now only directional lights illuminate terrain properly. We’re working on the rest.
Looks like I found a bug then. The skybox should not be lit then if the light source can be turned off. Here are all the results to further demonstrate the issue. Maybe in the mean time I can just switch the skybox to a night sky. Here are the shots where I can’t seem to stress the black on the terrain which should not be there but it is. More in next post, I can only do 3 attachments at a time.
Here are the rest of the shots. The basic scenario is this, I want to just create my own light source have it properly light the terrain, bout it really. I’ll wait until you get the rest of the light sources working against the terrain since I think Spotlight would fix this problem in general (although maybe not the black area)
I don’t think so–skyboxes don’t use lights at all (wouldn’t make sense for something that’s infinitely far away and not actually part of the scene in a conventional sense). I’ve seen no issues with lighting terrains, aside from only directional vertex lighting working, but UT is well aware of that, and they’re working on it as they said.
A directional light works fine. A spotlight would be the worst choice, as it is the slowest, and really not intended for lighting large areas. If you don’t want solid black areas, then turn the ambient lighting back up maybe? It looks like your light is nearly parallel to the terrain, so naturally not much is going to be lit. Try turning it so that it’s aimed more down at the terrain, not across.
As Alpha-Loup said, directional lights are infinite, and have no position in 3D space. You can put one at 0,0,0 or 3492,-3483,2855 and it will make no difference at all. The only thing that matters is the rotation.
I just ran an experiment with “sun” lighting, simulating the light effects as the sun rises, travels across the sky, and sets.
Edit → Render Settings → Ambient Light is set to pure black.
Placed a simple terrain spanning 0,0 to 2048,2048; center at 1024,1024.
Added the sunset skybox to the camera.
Placed a directional light and attached a script so it always pointed towards 1024,1024 (using LookAt).
And this is what I saw:
The terrain was lit correctly as the directional light traveled trough the sky, above the horizon.
The terrain was lit when the directional light passed beneath it. Therefore, the directional light must be turned off when below the horizon. (This was expected.)
The skybox was always self-illuminating and not affected by the directional light. (This was expected.)
The skybox could be dimmed by changing the material → tint color attribute. (This was expected.)
Even when the skybox tint color is pure black and all lights are off, the skybox remains illuminated a fair amount. (This was not expected.)
From this experiment I would surmise that the RenderFX/Skybox shader has an anomaly, in that it is always illuminated even when the tint color is pure black. This may be by design, but it is not what I expected.
I think this is an artifact of the method used to allow overbrightening. As it is, 50% tint = full brightness, but you can lighten it more than that. If you make a new shader that’s the same as the skybox shader, but you change all instances of “combine texture ± primary” to “combine texture * primary”, then you can have a pure black skybox when the tint is set to pure black. But then you can’t overbrighten it, either…100% tint = full brightness in that case.
I want to get rid of ambient lighting all together. I want the light to be pure to the other light sources. Add ambient lighting to the other light sources if need be, but get rid of the ambient from the render settings menu all together and apply it only to the ‘other’ light sources. If I have ambience, I want it to be specific to the other light sources and not a global setting in my case. I understand where you are coming from on the rest of the subject, I really do. Based on earlier conversation they are working on terrain lighting from the other light sources. I can’t currently achieve the desired outcome for the lighting in Unity that I would normally be able to do naturally in DX9. I’ll post up some images of what I am talking about tomorrow night, have to pull out some old DX9 code.
What about combine texture * primary double? (Or combine texture * primary quad.) Would that allow over-brightening, while still bottoming out at 0?
I dug around the wiki, and it looks like Aras had posted a blended skybox shader, which might also do the job.
[Edit: I just tried the blended skybox shader, replacing the “± primary” expressions with “* primary double.” I dropped in the sunset and blue sky textures. Tint color combined with the blend property provide excellent results for controlling day/night, with the ability to darken to 0 or over-brighten.]
This can be done. Drop in a new shader for the skybox (see above, with modifications) and turn off the ambient lighting. The directional light will control the lighting on the terrain and the tint color + blend properties will control the lighting of the skybox. Below is some code that accesses tint color and blend. This code assumes the skybox is global, set through Edit → Render Settings.
var color = Color(0.5, 0.5, 0.5, 0.5); // just an example color
RenderSettings.skybox.SetColor( "_Tint", color );
RenderSettings.skybox.SetFloat("_Blend", 0.5); // just an example
First you have the terrain. Ambient in render settings is black, your directional light shines horizontally, so it illuminates only one side of the hills. The rest of the terrain is black. This is correct behaviour in my book.
Then the skybox. Built-in skybox shader does not illuminate anything; and it’s not affected by lights at all. It’s just a texture plus a tint color that can make it up to 50% darker or up to 50% brighter. If you want your skybox to behave somehow differently, just write a custom shader that does exactly what you want.
That effect is close to what I want, but I think I need to play with creating a custom skybox shader. Directional light (aka 360 degree light) was not on the horizon it was in the sky, and the lighted hills were ok, but the base terrain was black. So this is incorrect behavior. I can’t seem to explain the fact that there was no horizon light at all. The light was in the sky, the terrain was lighted like the light was on the horizon, but it simply was not there. Now, if it was at the horizon, then I would expect only the hills to be lit and the black area to be black. I’ll get the chance to play around with it more in detail and do more screen shots tonight when i get off work and supply other shots as to what else i am trying to accomplish. Thanks everyone again for all the hints and ideas.