SteamVR

SteamVR

SteamVR Workshop
Customize your SteamVR experience by finding new backgrounds, 3D environments, controllers and base station models.
Learn More
glottis 1 3 Mar, 2020 @ 3:30pm
Hammer Lighting questions -- light render distance
Hello, sometimes lights in my map aren't rendered when I am a certain distance away. This causes a 'flickering' kind of effect, where the light pops in and it is very distracting. I don't think I am 'too far' from the lights where they shouldn't be rendered, since my map isn't very large or detailed. It's a house L600xW700xH280 sitting on a plane that is 2500x3000. The house is 2 floors and has around 8 rooms, with a couple Spot lights in each in the ceiling pointing down and 1 Directional for the sun. In total there are 1 Directional and 18 Spotlights. The problem is because since there are sightlines crossing through 3 rooms, more lights need to be rendered at a time, and the room at the far end doesn't get it's light rendered because of that.

I have followed this tutorial:
https://developer.valvesoftware.com/wiki/SteamVR/Environments/Environment_Tutorial:_Hammer_and_Basic_Lighting#Basic_Lighting

And I have also checked this thread out:
https://steamhost.cn/steamcommunity_com/workshop/discussions/-1/1759104780480857348/?appid=250820

And the things I have tried from there:
There's a limit on the total number of per-pixel direct lights being rendered at any one time.
Is there a way to know the limit? Would 18 Spotlights be pushing it?

Another trick is to set the 'Direct Lighting' to 'Baked' instead of 'Per-Pixel'; this will put the direct component into the ambient vertex lighting and will become effectively free to render.

Because of this suggestion I have made all of my Spotlights direct lighting to Baked. This didn't seem to do anything aside from changing the entity color from red to green-ish, as in there is still the pop-in lighting, after re-baking and everything.

It's stated that baked lighting is basically 'free', and the lights are popping in and out because of hitting come kind of render limit, but I thought that with baked lights this wasn't the case? It certainly is hitting some kind of render limit because just Translating one of my lights out of view causes an non-rendered light to pop back in.

Also, in that thread there is mention of a light_importance_volume entity as well as a env_combined_light_probe_volume. I do have around 5 env_combined_light_probe_volumes, but I am unsure how to use them properly, is it 1 per room (as in the tutorial), or larger spaces can be more spread-out? Do we need one for the outside? What is the strategy for using light_importance_volume entities (I have none so far)?

I have also set the light Shadows to Baked Only, to see if it would make any difference but it doesn't.

It appears that the lights on the second floor factor into the render count, even if I am on the ground floor. Meaning that I can select a light on the second floor, and while I am completely out of view and cut off from it via walls and floors, if I delete it the non-rendered light on the ground floor will turn on. Does this mean that I need to completely enclose my lighting, maybe there is a tiny crack somewhere where a light is peeking through to the ground floor, and being factored into the render?

Sorry for the noob questions.
< >
Showing 1-7 of 7 comments
Praxeos1 4 3 Mar, 2020 @ 4:07pm 
I'll attempt to answer with my admittedly limited (and occasionally inaccurate) knowledge: I have a long hallway full of lights in one of my environments. It was far less than 18 lights and was having a lot of blinking issues. I solved the problem by changing every other light to a baked light. As for the lights upstairs causing problems, I believe the problem may be exacerbated by the range of the lights intersecting each other. If you use the "helper" icon at the top of the level editor, you will be able to see a mesh representing where the range of your light. Shortening the range may solve the problem. You may even be able to fix your spotlight problem by narrowing the cones and ensuring that fewer are intersecting. I'm not sure of the exact number, but I don't think you can get away with more than 3 lights intersecting at one point. Regarding the light probes, I believe they create cubemaps of the area and bake lighting based on that. This means that you should set the probe somewhere near the center of the area, approximately head-level, and extend the box no further than what would be visible from that center point (i.e. I wouldn't have it go into other rooms).
Praxeos1 4 3 Mar, 2020 @ 4:11pm 
Oh, also, you will need to clear the old baked lighting and re-bake it every so often (menu option at the top) to create new cube maps. Do this after you have made significant changes to the environment and before you build your map. if objects look strangely dark or have unusually black shadows, it's an indication that you probably need to bake the lighting again.
glottis 1 3 Mar, 2020 @ 5:32pm 
Originally posted by Praxeos1:
I'll attempt to answer with my admittedly limited (and occasionally inaccurate) knowledge: I have a long hallway full of lights in one of my environments. It was far less than 18 lights and was having a lot of blinking issues. I solved the problem by changing every other light to a baked light. As for the lights upstairs causing problems, I believe the problem may be exacerbated by the range of the lights intersecting each other. If you use the "helper" icon at the top of the level editor, you will be able to see a mesh representing where the range of your light. Shortening the range may solve the problem. You may even be able to fix your spotlight problem by narrowing the cones and ensuring that fewer are intersecting. I'm not sure of the exact number, but I don't think you can get away with more than 3 lights intersecting at one point. Regarding the light probes, I believe they create cubemaps of the area and bake lighting based on that. This means that you should set the probe somewhere near the center of the area, approximately head-level, and extend the box no further than what would be visible from that center point (i.e. I wouldn't have it go into other rooms).

Hmm, I've tried what you suggested, but I can't tell if it works or not. It appears the problem is with what lights the *player* is intersecting, since moving out of certain cone ranges appears to render the lights correctly. I also did what you said and tried making some of them baked and some spot, and I think it fixed it in one area. I basically made the distant light that doesn't render baked lighting, and it stayed 'lit' while I was moving 'out of range' of it or whatever....

But I don't think baked lighting actually does anything? In the lighting options there are 4 places to set Baked that's in Shadows -> Cast Shadows, Render Specular -> Bake Into Cubemaps and Direct Lighting and Indirect Lighting. Setting all 4 of these to Baked, and this should effectively allow me to render more of them? But I still encounter the same problem with not being able to render distant lights if I'm within range of *x* lights (I don't know what the conditions are to render or not render a light), whether they are baked or not.

For the moment I've been playing with the End Fade Dist so I can kind-of control more which lights are shown and when. But it is not ideal.
Praxeos1 4 3 Mar, 2020 @ 8:13pm 
Ahh, that reminds me that I used the End Fade Dist feature too. Thinking about it further I'm probably wrong about the lights intersecting each other. It's reasonable to assume that rendering multiple lights within the player's view would be resource-intensive, regardless of whether they intersect. The range of the lighting might still be the problem with the upstairs if it extends downstairs (even if it is not obviously perceptible), but I'm only speculating.

It sounds like you did everything correctly for the baked lights. I'm pretty confident, that my recommendations for those are correct. Baked lights should not contribute to your lighting problems. The effects of dynamic lights are continuously recalculated in-game. They cast shadows for physics props and your controllers/hands. Baked lights, however, are all calculated ahead of time. Their effects and shadows do not change. They are essentially just painted into all the textures. I'm not sure how many lights you baked, but 18 lights is a lot to start with. You probably will need to make some big trade-offs. In comments from Valve developers, I've seen them state that multiple lights tend to quickly cause a lot of problems. That has been my experience so I always think very carefully about how to make the best use of the fewest lights. Contrary to my previous statement about narrow cones, the answer is probably to use far fewer lights with broader cones to cover a bigger area (i.e. fewer lights in the player's view).
Rectus 13 3 Mar, 2020 @ 11:44pm 
Seems like they changed the baked lighting behavior recently when they added lightmap support. If you bake the lighting inside Hammer, it won't bake the direct component anymore, and just shows the realtime per-pixel light instead. To make the baked ligthting work properly, you will have to turn on the Generate Lightmaps option in the build dialog under Custom Settings. The resulting lighting will not show up in Hammer though.

Oh, and the maximum number of realtime lights visible at once is 16.
glottis 1 5 Mar, 2020 @ 5:15pm 
Thank you both for your advice, I have reduced the number of total lights in my environment, and no more flickering issues. But yea now I have to fiddle around with more light settings until the rooms aren't so dark anymore.

I have not tried Generate Lightmaps yet, but I will definitely later to see if it actually does bake the lights. Because you're right, I still see shadows under my "baked" lights, even after specifically clearing and re-baking the lights. I wonder why the *real* baked lights option is in the build window and not under, Baked Lighting, as one would assume?

EDIT: Thank you Rectus. I did a Generate Lightmap and it did indeed bake the lights as expected. Now I guess I need to strategically place per-pixel lights so that the player's hands aren't always completely black... But what do I have to work with here, am I to assume that I can place as many baked lights as I want since they're cheap renders, but realtime lights I am limited to 16?
Last edited by glottis; 5 Mar, 2020 @ 6:57pm
Rectus 13 5 Mar, 2020 @ 11:54pm 
Yeah, baked lights should be practically free. You can have more than 16 real time lights, but the furthest away will just stop rendering, so it's more like 16 lights per area.
Last edited by Rectus; 5 Mar, 2020 @ 11:56pm
< >
Showing 1-7 of 7 comments
Per page: 1530 50