feat: Skybox light fog - #3309
Conversation
|
🤖 Draft PR — automatic CI is skipped to save runner minutes.
|
|
I like the effect, but would this not be better as a fog component that samples a texture where you could set there the skybox or any other thing (an arbitrary |
|
@Ethereal77 There are two reasons why I moved it to be part of the skybox light:
There's probably a better way to do this, which is why I'm leaving this as draft for now, and would like to hear any further ideas you might have. But I do want to ensure we're not adding more friction for users, it's already a bit stupid to have to swap the texture used in the background component and the skybox asset whenever we want to change the skybox used for a scene. No one in their right mind would keep these distinct, it just looks amateur-ish. |
I have always seen the skybox light as just a environment map to use for lighting in PBR, not as an atmospheric scattering simulation, which I see more as "volumetrics".
Yes, I know it would be (and look) weird if the cube texture used is different. I was just talking about differentiating light contribution from volumetric effects.
I myself won't do it normally, and for realistic rendering, but I've seen weird stylistic effects over the years by people that tried weird things no one in their right mind would do 😁 |
Simulate as in approximate, like how a skybox approximates the sky by having it painted, or otherwise pre-rendered on a texture to then be projected around the player. Or how an environment map approximates the light an object would receive if it where in the environment depicted in the one captured.
Definitely, but I don't think it make sense to have this sort of friction for the 1% that might find it useful. Even more so when you have other ways to do so. |
|
I think you’re misunderstanding my words. What I’m saying is just that imo these two concepts must be separated. I think a light should be just a light (i.e., affect an object's shading as if it was in an environment projecting light on it), and a volumetric effect is a separate concept (i.e., "participating media" simulation and all that, even if only a simple approximation), just like light shafts are implemented today. I'm not arguing whether it makes more or less sense that the fog and the skybox have the same cube texture. Of course, the most probable use of such a feature would be to have the same texture, I agree. I'm not opposed to a basic implementation of these "simple" cubemap fog. I may find such an effect useful myself. What I fear is a "hacky" implementation solidifies and later would be difficult to refactor into the good solution if/when we improve how the renderer draws volumetric effects (which we'll need at some point). |
|
I did understand your position, I was simply clarifying mine. Like I said:
I think it makes more sense to have such strong dependencies within the same component because of the aforementioned issues with friction on the user side, and redundant logic on the engine side. But it doesn't hold that much water given the background-cubemap/skylight split, and how it really is more dependent on the background itself, so I'm not set either way. 'just want to pick your (and other maintainers) brain on what else we could do, like I mentioned previously. Should I setup a new component which handles both the 'background' and the fog given that they have to be in sync ? |
|
Ok. I dont want`to appear too stubborn on this. I'd also want to hear the opinion of other mantainers. I'm currently far from my main workstation, so I can't do much. But I'd like to see how light shafts are specifically implemented, to see if the volumetrics part could be expanded and improved, and effects like this one or others could be added.
Is there a way to create a template that adds two components at once? If that were possible, you could keep the two components, but add them and configure them in one go.
This is why I talk about a global "volumetrics" pass in |
We could but I don't believe this is as much of an issue here; the main thing I'm trying to avoid is having to tweak the background component, the sky light component and the fog component whenever the user wants to swap the skybox. This is a pain in the ass when, for example, one has a bunch of different skyboxes available and is doing look-dev; testing them out to see which one works best, producing multiple versions and comparing them. Here's what we've discussed, and what I can think of:
The above is a response to
I'm not sure whether you implied that we move all of this to the graphics compositor. I commented on that point none the less as if that was the case. |
I know it would look glaringly wrong in many cases, but for fixed-camera scenes... maybe it would sample the background even if it is a regular 2D texture, or even better, a color or Also, picture another use case I have also seen sometimes. A fake "preview" scene where the background is a static dark image (either 2D or cubemap), but the light is set to a cubemap so the object being previewed at the center looks shaded or lit in a certain way. For example, the typical car selection screen of the Grand Turismo titles.
Yes, more or less. I was talking more about the future, when we may want to add better volumetric effects. If it was part of the compositor, maybe a dedicated fog pass (later volumetrics, if we have more) could be configured to sample from several sources:
Maybe it could default to Background, so your use case always works without setting anything more. That is more in line with the "volumetrics" idea I had. |
Yeah, we could adapt the implementation used based on whether it's a texture or a cubemap, but we can't use an arbitrary ComputeColor;
I don't see why they would need a fog whose purpose is specifically to blend into the skybox, and then use a different skybox, they may as well use the simple fog at that point. Even then, they can work around this by setting up a plane without diffuse shading to act as the skybox, or add another background component overriding the first one.
We can't have everything setup through the compositor, again, users need to define whether there is fog within a given scene, and what the parameters for this fog would be. We need at least a toggle somewhere on some component or on the scene asset. |
Well, I said
Currently
This one I'm not understanding. A
I don't understant this one either. Are we talking here about generic "computecolors", or specifically of something else? Because there exists
Well, of course you can use a million tricks. But what I'm trying to ideate is an intuitive and flexible way it works most of the time, and one that does not hinder us later if we want to expand this feature.
As I said in another thread (#3299), what I have in mind --even if it is a big reformulation of current rendering-- is a compositor with more flexible configuration of the pipeline (similar to a render graph), instead of the current one with many hardcoded paths and conditions inside I know this is a big change that we all would need to discuss and design carefuly. But I hope you see where I go with this |
Sure, we might need to justify its existence though, that's a lot of additional API for just this feature, ultimately, fairly small feature
Well, I was thinking you wanted to go with using
A generic Obviously, that doesn't matter if we the base type we accept is not
That is fine to me, I should have emphasized that when I meant all of this I was thinking you wanted to remove the component as well. Although, it would be counterintuitive for users when they try to figure out why their fog component doesn't work, that they have to add the feature to the graphics compositor... |
Well, yes. For this use case of the fog, it's a niche feature. But a
Of course. A But I said above, I think there is value in having a
Well, the feature can be already there, just as a no-op if no fog is configured. Today, the hardcoded light-shafts path in |
How would you see the SDSL API for that, naively we could introduce
Lightshafts are not enabled by default, one has to assign the reference afaict. But yes, we could have the default setup with it on and expect users are not distracted to a point where they forget they disabled it there when wondering why they don't have fog. |
PR Details
Adds a fog feature to the skybox light, this is different from the fog post process as it matches the skybox used instead of having a singular color used for the whole range.


The idea is to sample the skybox over the surface, increase in mipmap res the further the surface is.
Mar Saba Monastery model belongs to Andrea Spognetta
Related Issue
None.
Types of changes
Checklist
The implementation is kind of hack-y. Hoping Xen2 or Youness could push me in the right direction. On that note, current questions regarding the implementation:
BackgroundComponent's skybox used, not the lights' parameters. So we could split it off of the light either as a new component or something else ?BackgroundComponentis not guaranteed to be set to a skybox, it could be a 2d texture. We could branch this implementation to handle the different parameters of the background appropriately. But I'm not seeing an obvious way to do so cleanly.Distance,Curve,NearMip, etc. be generics or leave them asPerView.Lighting? If they should, how would I set that up.