Dampe:
It's not retarded. :-)
I have stars in the background of my space scene. I don't want them to be fogged. Nor do I want my nebulas to be fogged. Or my scoreboard.
But I do want aliens which have just spawned and are rendered in front of the stars to take on a bluish fog effect so that the player will be able to tell that they are not part of the foreground, and thus, not yet shootable.
you can't have a black background, with an object effected by white fog. You'll have a grey background. That white fog will lighten up the background.
But you also don't want an invisible object to look like a white cloud moving over objects that are behind it because fog is still affecting it 100%.
The way I have set up fog is correct in this respect. You can set the fog of your sprites according to the distance from the camera, and the effect will be 100% correct. If you did it the way you're saying then any sprite with alpha near 0 would render like a nearly solid white cloud and look all wrong.
The only way to get a "proper" fog effect would be to, for every Z level a sprite is drawn at, render a solid fog square covering the whole scene and that sprite and all sprites at that Z distance with the transparency set to get the appropriate amount of additional fog. This would add on top of all the layers that were drawn behind it with fog as well. Otherwise you'd only get this additive effect where the individual sprites are and that wouldn't be correct, unless you give up completely on allowing any transparency.
Unless we are talking about some un-realistic magic fog that doesn't do what real fog does... in which case... why are you bothering with any kind of realism in the first place?
There was a very speciifc effect I wanted to get. I wanted to get the effect of a semitransparent solid color version of a sprite rendered over a semitransparent regular version of a sprite, and I wanted the overall effect to have the same level of transparency as the sprite was supposed to have in the first place.
In other words, I wanted to recreate the effect of a photoshop layer with my sprite, with another layer colored blue grouped with that layer. Both have alpha you can set, but the alpha of the parent layer is what sets the overall alpha. The alpha of the child only affects the color of the parent layer, not the overall transparency of it.
I also wanted this effect to be useful for simulating fog. And it is entirely useful for that. With the fog getting more transparent as the sprite does, the overall effect is fairly realistic. It may not be 100% accurate, (or maybe it is, I don't know.) but it's close enough.
Is it better to simulate fog perfectly, or simulate it closely, but also give the user the ability to make artistic decisions about how objects in the world are affected by it, and for them to be able to use it to make objects flash white momentarily? I say the latter is more important.
Making a game fun doesn't mean making it make perfect sense. When mario gets that cape and you want him to interpolate from normal to pure white over the course of a second to indicate he is powering up, you'll be glad I did it this way. :-)
If your sprites have outlines.. like cartoons.. you would have to have a fog-map to define the areas less effected by the fog. so you don't bleach out the outlines which defy logic.
I don't think I've seen a cartoon where they don't bleach out the lines as a character moves into fog. That would look really weird.
It's not retarded. :-)
I have stars in the background of my space scene. I don't want them to be fogged. Nor do I want my nebulas to be fogged. Or my scoreboard.
But I do want aliens which have just spawned and are rendered in front of the stars to take on a bluish fog effect so that the player will be able to tell that they are not part of the foreground, and thus, not yet shootable.
you can't have a black background, with an object effected by white fog. You'll have a grey background. That white fog will lighten up the background.
But you also don't want an invisible object to look like a white cloud moving over objects that are behind it because fog is still affecting it 100%.
The way I have set up fog is correct in this respect. You can set the fog of your sprites according to the distance from the camera, and the effect will be 100% correct. If you did it the way you're saying then any sprite with alpha near 0 would render like a nearly solid white cloud and look all wrong.
The only way to get a "proper" fog effect would be to, for every Z level a sprite is drawn at, render a solid fog square covering the whole scene and that sprite and all sprites at that Z distance with the transparency set to get the appropriate amount of additional fog. This would add on top of all the layers that were drawn behind it with fog as well. Otherwise you'd only get this additive effect where the individual sprites are and that wouldn't be correct, unless you give up completely on allowing any transparency.
Unless we are talking about some un-realistic magic fog that doesn't do what real fog does... in which case... why are you bothering with any kind of realism in the first place?
There was a very speciifc effect I wanted to get. I wanted to get the effect of a semitransparent solid color version of a sprite rendered over a semitransparent regular version of a sprite, and I wanted the overall effect to have the same level of transparency as the sprite was supposed to have in the first place.
In other words, I wanted to recreate the effect of a photoshop layer with my sprite, with another layer colored blue grouped with that layer. Both have alpha you can set, but the alpha of the parent layer is what sets the overall alpha. The alpha of the child only affects the color of the parent layer, not the overall transparency of it.
I also wanted this effect to be useful for simulating fog. And it is entirely useful for that. With the fog getting more transparent as the sprite does, the overall effect is fairly realistic. It may not be 100% accurate, (or maybe it is, I don't know.) but it's close enough.
Is it better to simulate fog perfectly, or simulate it closely, but also give the user the ability to make artistic decisions about how objects in the world are affected by it, and for them to be able to use it to make objects flash white momentarily? I say the latter is more important.
Making a game fun doesn't mean making it make perfect sense. When mario gets that cape and you want him to interpolate from normal to pure white over the course of a second to indicate he is powering up, you'll be glad I did it this way. :-)
If your sprites have outlines.. like cartoons.. you would have to have a fog-map to define the areas less effected by the fog. so you don't bleach out the outlines which defy logic.
I don't think I've seen a cartoon where they don't bleach out the lines as a character moves into fog. That would look really weird.