Shady Planet...

Thinking about improving the Artwork in Vega Strike, or making your own Mod? Submit your question and ideas in this forum.

Moderator: pyramid

hurleybird
Elite
Elite
Posts: 1671
Joined: Fri Jan 03, 2003 12:46 am
Location: Earth, Sol system.
Contact:

Post by hurleybird »

wow :shock:
charlieg
Elite Mercenary
Elite Mercenary
Posts: 1329
Joined: Thu Mar 27, 2003 11:51 pm
Location: Manchester, UK
Contact:

Post by charlieg »

Looking really good.

I've just realised, though, why the specular reflection is wrong. Water isn't reflective at high angles and also the sun doesn't act like a torch, like a focused source of light. It casts light out evenly in all directions. You just wouldn't get a reflection of the sun like you have here. Between the way the sun casts light and the diffraction in the air, and the reflective properties of water, you just don't get such reflections visible from space. The picture you showed before was still within the atmosphere and, notably, at a low angle. (Even paper reflects light at low angles.) From a high angle, water just isn't that reflective.
chuck_starchaser
Elite
Elite
Posts: 8014
Joined: Fri Sep 05, 2003 4:03 am
Location: Montreal
Contact:

Post by chuck_starchaser »

You're right about the high angle producing less reflection. I've worked pretty hard on the shininess formula and I'm far from done yet. I think OpenGL's standard formula is a gross simplification, even for solid specular materials, and definitely doesn't go well with water. I saw a picture somewhere of precisely the sun's reflection on the ocean from space, but I lost the link. It was a bit smaller than I have it presently, but pretty bright, non-the less. I wish I had a set of pictures from various angles, but I spent many hours googling around and found nothing.
Shininess controls the size of the spot: The more shininess, the smaller the spot. The ogl formula per pixel is

Code: Select all

specular light = specularity * pow(dotproduct, shininess)
where specularity and shininess are material properties, and dotproduct is the dot product between the light's reflected beam and the camera's view vector, both normalized. I had to modify that formula to..

Code: Select all

specular light = specularity * pow(dotproduct, shininess*(0.2+atmo_alpha)
where atmo_alpha was just a convenient term that increased towards the horizon, because otherwise the spot would grow too big, and actually encircle the planet when you were in the dark side. Or else I would get a spot too small, at a high angle, if I increased the shininess; --which is not right, since the ocean has waves on the surface and that puts a bottom limit on how small the reflection can get. But I do need to reduce the intensity of the reflection at high angles. The thing is, I don't want to do another hack of the formula; I'm hoping to find what the formula for reflectivity should be. I used to know it: --it had something to do with the dielectric constant of the two mediums, and the squares of the sine's of the angles, or something along the lines...
chuck_starchaser
Elite
Elite
Posts: 8014
Joined: Fri Sep 05, 2003 4:03 am
Location: Montreal
Contact:

Post by chuck_starchaser »

I can't take it anymore; spent the whole day googling around for the formula for reflectivity of water and can't find it. If anybody here knows what it is, please help. Essentially, what I've been looking for is, given an angle of incidence between two mediums of diferent dielectric constants, part of the light is refracted, part is reflected. The refracted light changes in angle, but I don't care. The reflected light's angle is the same as the incident angle, but the intensity of the reflected light isn't; and I need a formula for intensity as function of the two dielectric constants and the angle.
I remember it involved the sines or cosines and the two dielectric constants. I also remember that going from a medium of higher dielectric constant to one of lower dielectric constant, there was an angle beyond which you had total reflectivity.
About 50 % of the links coming up in google are about radar signatures. Another 25 % or so are about detecting humidity in soil. Then there's the totally unrelated crap, and finally a few papers with formulas, but which formulas include everything about reflection and refraction EXCEPT a formula for intensity of the reflection, or which have formulas for intensity of reflection but burdened with all kinds of details like polarization and stuff. I just need the simpler formula.
dandandaman
Artisan
Artisan
Posts: 1270
Joined: Fri Jan 03, 2003 3:27 am
Location: Perth, Western Australia
Contact:

Post by dandandaman »

You're thinking Fresnel reflection:
http://en.wikipedia.org/wiki/Fresnel_reflection

Is that what you needed?

Dan.a
"Computers are useless. They can only give you answers."
-- Pablo Picasso
chuck_starchaser
Elite
Elite
Posts: 8014
Joined: Fri Sep 05, 2003 4:03 am
Location: Montreal
Contact:

Post by chuck_starchaser »

Thanks dan, I saw this fresnel reflection coefficient during my browsing, but I know that the power of the reflected light changes with the angle. In fact, right under the formula in you link it says "In general, the greater the angle of incidence with respect to the normal, the greater the Fresnel reflection coefficient, but for radiation that is linearly polarized in the plane of incidence, there is zero reflection at Brewster's angle." And yet, the formula has no term or factor related to the angle of incidence. Even following all the references off your link doesn't seem to lead to a formula for the intensity of the reflection.
chuck_starchaser
Elite
Elite
Posts: 8014
Joined: Fri Sep 05, 2003 4:03 am
Location: Montreal
Contact:

Post by chuck_starchaser »

Found it! :-) From this website and following links off it, got the picture:

n = refractive index

Examples:
n for vacuum = 1
n for air = 1.000277
n for water = 4/3
n for diamond = 2.417
n for ice = 1.31
n for glass and polystyrene ~= 1.6

Refraction angle:
sin( A water ) = (n air/n water) sin( A air )
n air / n water ~= 0.75
therefore
A water = arcsin( 0.75 * A air )

Reflection for polarization along the vertical plane of incidence:
rv = tan( A air - A water ) / tan( A air + A water )

Reflection for polarization that hits the water sideways:
rh = sin( A air - A water ) / sin( A air + A water )

And intuitively I'd say that for non-polarized light, reflection intensity should be:
r = sqrt( rv^2 + rh^2 )

Now I have to find out whether there's a way to simplify the formulas, or whether I'll have to plot values and find a polynomial approximation... :-/

EDIT:
Sorry, my last, "intuitive" formula was wrong. For an incident angle of 90 degrees it gives a reflecte intensity of root-2...
dandandaman
Artisan
Artisan
Posts: 1270
Joined: Fri Jan 03, 2003 3:27 am
Location: Perth, Western Australia
Contact:

Post by dandandaman »

Yep, I also knew about the polarisation ones, but I thought you would have only wanted non-polarised stuff? If these are good, then whoops ;-)

If they aren't, and you don't know a way of smushing them together to get something, can't you just try some approximations that fit the boundary conditions (I'm thinking a fourier expansion might be good), and tweak it until it looks right? I suppose I'm asking, how accurate do you want to do this? :-)

Dan.a
"Computers are useless. They can only give you answers."
-- Pablo Picasso
chuck_starchaser
Elite
Elite
Posts: 8014
Joined: Fri Sep 05, 2003 4:03 am
Location: Montreal
Contact:

Post by chuck_starchaser »

I plottet values between 0 and 90 degrees, at 10 degree intervals, and then averaged the results for the two polarizations, and this is what I get, from 90 down to 0:

90 0.9999
80 0.5824
70 0.3431
60 0.2024
50 0.1407
40 0.1421
30 0.1425
20 0.1426
10 0.1427
00 0.1425

Pretty weird, huh? I decided to average the two polarizations because I figured if one were to measure ligth intensity in two polarizations, probably each would show half as much amplitude? Not sure...
In any case, I think I'll use .14 up to 55 degrees, and then some adhoc aproximation.
Yeah, I would have preferred a formula without polarization details, but there doesn't seem to be one floating around.
chuck_starchaser
Elite
Elite
Posts: 8014
Joined: Fri Sep 05, 2003 4:03 am
Location: Montreal
Contact:

Post by chuck_starchaser »

Update:
I've roughly approximated the table of values above by using...

Code: Select all

   fresnel_reflection_intensity = sqrt( (1-cos(alpha))^4 + 0.14^2 )  
(in other words, (1-cos)^2 sort of approximates the high angle zone, and then I do a root mean square with the base value, 0.14, to make it be so, while avoiding sharp discontinuities)

... and now the sun's reflection dims pretty realistically as it passes in front.
I'll get back to work on the clouds' shadows problem.
chuck_starchaser
Elite
Elite
Posts: 8014
Joined: Fri Sep 05, 2003 4:03 am
Location: Montreal
Contact:

Post by chuck_starchaser »

Here's some snapshots of the fresnel reflection function in action:

Image
Full size here.

Image
Full size here.

Image
Full size here.

Image
Full size here.

I'm not entirely sure about what the absolute intensity of the reflection should be, though, I just tuned it by ear... er.. by eye. It would seem to me that, even at a fresnel multiplier of 0.14, specular reflection should be hundreds of times more concentrated than diffuse reflection, but then there's the ocean waves factor to consider...
Last edited by chuck_starchaser on Fri Jun 03, 2005 9:55 pm, edited 1 time in total.
smbarbour
Fearless Venturer
Fearless Venturer
Posts: 610
Joined: Wed Mar 23, 2005 6:42 pm
Location: Northern Illinois

Post by smbarbour »

Looks great. Maybe it's just me and I've never seen a reflection from space, but the reflection almost seems muddy in color. It's probably just me.
I've stopped playing. I'm waiting for a new release.

I've kicked the MMO habit for now, but if I maintain enough money for an EVE-Online subscription, I'll be gone again.
chuck_starchaser
Elite
Elite
Posts: 8014
Joined: Fri Sep 05, 2003 4:03 am
Location: Montreal
Contact:

Post by chuck_starchaser »

I've been working on the assumption that, on average, specular colors of materials would be complementary to the diffuse color. I made up this rule out of the blue.. well, I figured, the more green light a material scatters, the less green light is left for it to speculate; --and viceversa. Ocean water is diffusely blue, in fact, color picking off the NASA texture for Earth, ocean color is 0.04, 0.04, 0.31 --RGB values.
So, I divided .31 by .04 and got a figure 7.75; I made the material specular color 1.0 for red and green, and then divided 1.0 by 7.75 to get 0.13 for blue.
But maybe I should have subtracted diffuse light from incident (1,1,1) and then I would obtain, let's see... (0.96,0.96,0.69).
Perhaps this is not right, though. I'm not even sure why the ocean looks blue, to be honest; I haven't been near a beach for quite a while, but I don't remember the water looking like Windex. Maybe blue light enters the water but gets scatterd by the salts repeatedly, such that some of the blue light jumps right back out of the water, but red and green being longer wavelength don't get scattered back out nearly as often.
If this is the reason for oceans looking blue, then perhaps specular color ought to be unrelated to diffuse color.
EDIT: I just tried (0.96,0.96,0.69) and it looks okay, well, pretty whitish... I might settle for something inbetween, for the time being.
smbarbour
Fearless Venturer
Fearless Venturer
Posts: 610
Joined: Wed Mar 23, 2005 6:42 pm
Location: Northern Illinois

Post by smbarbour »

Ah-ha! The oceans are not "actually" blue, it is merely the reflection of the sky.
I've stopped playing. I'm waiting for a new release.

I've kicked the MMO habit for now, but if I maintain enough money for an EVE-Online subscription, I'll be gone again.
pontiac
Elite
Elite
Posts: 1454
Joined: Sun Jan 12, 2003 6:24 pm
Location: Far out in the uncharted backwaters of the unfashionable end of the western spiral arm of the Galaxy
Contact:

Post by pontiac »

smbarbour wrote:Ah-ha! The oceans are not "actually" blue, it is merely the reflection of the sky.
When we are at that topic: the sky isn't actually blue as well ;)

Pontiac
hurleybird
Elite
Elite
Posts: 1671
Joined: Fri Jan 03, 2003 12:46 am
Location: Earth, Sol system.
Contact:

Post by hurleybird »

The highlight looks really good at an angle, but still looks a bit off when viewed head on.

IMO, the cloud shadows are amazing, not sure how hard they were to do, but you did a very good job on them.

Have you had a look at celestia? They seem to have done a pretty good job on specular highlights.
chuck_starchaser
Elite
Elite
Posts: 8014
Joined: Fri Sep 05, 2003 4:03 am
Location: Montreal
Contact:

Post by chuck_starchaser »

smbarbour wrote:Ah-ha! The oceans are not "actually" blue, it is merely the reflection of the sky.
I see! Of course! Between air and water there's either refraction (absorption), or Fresnel specular reflection. There's no such thing as "diffuse color" for water. So the blue we see is specular reflection of a diffuse source, that being atmospheric scattering. ** Bangs head on kyboard ... "ghjfdk jjfda jgkfld;asjl jgkf;a"
pontiac wrote:When we are at that topic: the sky isn't actually blue as well ;)
Seen from Earth, it's definitely blue. Seen from space, I'm not entirely sure. Thing is, the atmosphere is so thin you can hardly see it from space. Only twards the horizons it gets thicker due to the angle of the view vector. I'v already worked out a formula to compute the thickness of air the eye view goes through, and I'm computing it per-pixel; and if you look towards the horizon, you see things progressively whitening.
Now, whether they should be progressively "blueishing" I'm not entirely sure. Let me try it and I'll be back...


Pontiac
chuck_starchaser
Elite
Elite
Posts: 8014
Joined: Fri Sep 05, 2003 4:03 am
Location: Montreal
Contact:

Post by chuck_starchaser »

Yeah, looks much better with a blue atmo...

Image

Big shot.

Where it looks wrong in in pre-dawn and after sunset, of course, as when sunlight comes through the atmo, blue light is subtracted by scattering, making sunsets golden or reddish. I can't do that in the shader, at this point, though, because I'd have to pass the view and light vectors from the vertex shader to the fragment shader, but I'm already maxed out in "varyings", at 6 floats. What I CAN do, I believe, is hack the sun on the CPU side, so that it changes color as it goes behind the planet.
hurleybird wrote:The highlight looks really good at an angle, but still looks a bit off when viewed head on.
Yeah, I just changed the ocean's specular color from (1,1,.2) to (1,1,.6) rgb. Does it look okay now?
IMO, the cloud shadows are amazing, not sure how hard they were to do, but you did a very good job on them.
Thanks, but actually I haven't done anything with the shadows yet, I merely multiplied the pixel value by (1-cos(sunlightangle))*cloudshadowpixelvalue. The cloud shadow texture is almost an exact copy of the clouds texture, with just one smoothing filter pass. And the orientation of the shadows is always to the left of the clouds, regardless of where the sunlight is coming from. The shadow texture is simply rotated by a slight angle retative to the clouds texture. I'm just showing you pictures of the morning side, where that happens to look good.. :D
What I've been working on for the past couple of days is trying to work out formulas for stretching the textures. The shadows texture will get a little stretching away from the sun, to fake them being 'cast' by the sun. The clouds texture will get a similar stretch, but away from the camera, to fake paralax.
Have you had a look at celestia? They seem to have done a pretty good job on specular highlights.
Interesting. They make the specular color blue. I'm skeptical...
Gee! I'm doubly skeptical: I think I'm starting to understand something... The fresnel formula, some 10 posts back, notice that it has NO ocurrence of wavelength, whether as term or as factor. Maybe Fresnel specularity is white, and the only factor to consider is the travel of light through atmosphere, which gets blue subtracted by scattering, BUT, there would be very little scattering when the reflection is straight, aligned with the normal; as the thickness is minimal. But towards the horizon, the reflection should get yellower at twice the rate as the atmosphere gets blueisher...
hurleybird
Elite
Elite
Posts: 1671
Joined: Fri Jan 03, 2003 12:46 am
Location: Earth, Sol system.
Contact:

Post by hurleybird »

Nice picture, that high-light looks pretty good.

One thing that I notice (though it could be just me), is that high-lights look better when they are unobstructed by a land mass., and when they are obstructed, seem to look somewhat unatural. I dont know any formulas or anything, but wouldnt it look more naturally if the highlight slightly 'bent' around the landmass?
klauss
Elite
Elite
Posts: 7243
Joined: Mon Apr 18, 2005 2:40 pm
Location: LS87, Buenos Aires, República Argentina

Post by klauss »

The last comment, chuck, is the real thing. Specular highlighs take the color of the incoming light. For water specularity, it takes the color of the sun, modified by the atmosphere (reddish near the horizon - going tangential to the curvature of the earth, more white away from it - going perpendicular to curvature).

Except, fresnel refraction is dependant on wavelength, indirectly, since IOR is dependant on wavelength, and fresnel depens on IOR differential.

About the sunset thing, try using the angle of incidence of light, which you're already using for lighting calculations, and the surface normal. It should be enough, since you can assume uniform atmosphere density (which could be a uniform parameter).

The atmosphere is quite visible from space. Although all your screenshots look awesome, real pictures are much blueish. Think of it: the same blueness you see while looking into space (the sky), should be the blueness you see from it (why would it be different to travel in the other direction).

Take a look at this picture.

Notice too how the thickness of the atmosphere is quite noticeable. That's another thing to consider: your atmospheres are too thin. In fact, perhaps that's the only problem: make them thicker, and adjust density accordingly.

Really, when VS supports GLSL, the first things that will show it will be planets. How Awesome does it look?

I'm curious. I'll try to finish toxic_disaster (poor old planet, I left it somewhere between archival and oblivion... got too tangled with other things in VS). I'll finish it with the sole purpose of testing it with your code. Only, for that, it would be necessary to support specular maps, instead of using color keying.
Oíd mortales, el grito sagrado...
Call me "Menes, lord of Cats"
Wing Commander Universe
chuck_starchaser
Elite
Elite
Posts: 8014
Joined: Fri Sep 05, 2003 4:03 am
Location: Montreal
Contact:

Post by chuck_starchaser »

Amazing! I was just thinking about toxic disaster, and was going to email you about trying it on shaders. I was worrying about the green pollution going into the ocean, though, since that will be difficult to key onto, for specularity; --and it might look really odd to have a non-specular green blob in a speculating zone. ;-)
klauss wrote:The last comment, chuck, is the real thing. Specular highlighs take the color of the incoming light. For water specularity, it takes the color of the sun, modified by the atmosphere (reddish near the horizon - going tangential to the curvature of the earth, more white away from it - going perpendicular to curvature).
Okay, perfect; I'll get this change done in no time at all.
About the sunset thing, try using the angle of incidence of light, which you're already using for lighting calculations, and the surface normal. It should be enough, since you can assume uniform atmosphere density (which could be a uniform parameter).
I thought about that, but the angle of incidence is not enough. If the sun is behind you, that's when the color of the horizon should be the bluest, as light has to make a U-turn; and only blue ligt would dare... Whereas if the sun is on the other side of the planet, only red light and a bit of green get through. Yet, in both cases, the angle of incidence is the same. What I would need is, for each pixel, the dot product between the light and the camera vectors. I could compute this per vertex, but I cannot output it to the fragment shader, becaus I'm out of room. Six floats and you're toast. What I do have, however, is the dot product between the view vector and the light's reflection. I might be able to use that one, as I do have a reflection vector in the halo, since my atmospheric halo is a hack, anyways, --it is stolen from the planet, rather than added to it.. :D
The atmosphere is quite visible from space. Although all your screenshots look awesome, real pictures are much blueish. Think of it: the same blueness you see while looking into space (the sky), should be the blueness you see from it (why would it be different to travel in the other direction).
Take a look at this picture.
Almost convincing, except, notice that this picture is highly zoomed. So zoomed, in fact, that you hardly notice the curvature of the horizon. Very low orbit, of course, as most astronaut and ISS -taken pictures are. If you look at my last screenshot and mentally zoom in to a little square, 1 cm on the side on the screen, you'll see as much blue as on the picture in your link, I think.

Notice too how the thickness of the atmosphere is quite noticeable. That's another thing to consider: your atmospheres are too thin. In fact, perhaps that's the only problem: make them thicker, and adjust density accordingly.
I think that's also the zoom factor. My atmospheric halo, right now, I'll tell you exactly, hold on a sec... Doh! Now I can't tell you because I "optimized" that part of the code such that to subtract the halo from the planet I ended up using a magic number buried into atmo density formulas, but it's about 1.5% of the radius, which is way too thick IMO. And the only reason I made it that thick is to have at leas 4 pixels so that a thinning gradient would be noticeable at all. But, to do this properly, I should put a separate geometry, a ring, and draw the atmo halo there, rather than onto the planet itself.
hurleybird wrote:One thing that I notice (though it could be just me), is that high-lights look better when they are unobstructed by a land mass., and when they are obstructed, seem to look somewhat unatural. I dont know any formulas or anything, but wouldnt it look more naturally if the highlight slightly 'bent' around the landmass?
No, what looks unnatural is the thin line of ocean around coastal areas. Where the bottom of the ocean starts to become visible, the color changes slightly, and my color keying hack breaks down. I can try and reduce its sensitivity a bit...
dandandaman
Artisan
Artisan
Posts: 1270
Joined: Fri Jan 03, 2003 3:27 am
Location: Perth, Western Australia
Contact:

Post by dandandaman »

Chuck, just a question .. what's cheaper to use, a cos/sin series or polynomial expansion?

Dan.a
"Computers are useless. They can only give you answers."
-- Pablo Picasso
MamiyaOtaru
Privateer
Posts: 729
Joined: Tue Jan 07, 2003 8:32 am

Post by MamiyaOtaru »

chuck_starchaser wrote:
The atmosphere is quite visible from space. Although all your screenshots look awesome, real pictures are much blueish. Think of it: the same blueness you see while looking into space (the sky), should be the blueness you see from it (why would it be different to travel in the other direction).
Take a look at this picture.
Almost convincing, except, notice that this picture is highly zoomed. So zoomed, in fact, that you hardly notice the curvature of the horizon. Very low orbit, of course, as most astronaut and ISS -taken pictures are. If you look at my last screenshot and mentally zoom in to a little square, 1 cm on the side on the screen, you'll see as much blue as on the picture in your link, I think.
He wasn't only talking about the atmosphere visible on the horizon, but the bluish tinge given by the atmosphere to everything underneath it. Not only ocean, but land looks quite bluish as well. Just as looking up at space through the atmosphere makes it look blue, looking down at the planet through the atmosphere makes everything a bit more blue.

We don't live on "the blue and green planet" ;) I'd never thought about it before, but it makes sense. All the photos I can dig up show everything tinted blue. "Natural color" images made from various sensors aren't photographs, and tend to present the land as we would perceive it while up close, not how it looks filtered through the atmosphere..

Anyway I'm hardly an expert on the subject, but it merits looking into. Of course, whether it would improve a game is another issue entirely.
chuck_starchaser
Elite
Elite
Posts: 8014
Joined: Fri Sep 05, 2003 4:03 am
Location: Montreal
Contact:

Post by chuck_starchaser »

dandandaman wrote:Chuck, just a question .. what's cheaper to use, a cos/sin series or polynomial expansion?
Dan.a
On a CPU a polynomial, I'm sure; on a GPU no idea; depends I guess on whether trig functions are decomposed into successive approximations or done single shot (table and interpolation) or what, and I've no idea of the internals. I think that when you write a shader you are guaranteed full execution in a single cycle, with the condition that the entire assembled protram must fit the length of the pipelines. But if your question is a reference to the way I approximated the fresnel reflection curve, the cosine that I used was one that I already had computed in the vertex shader, and in fact was one of the "varyings" --one of the inputs to the fragment shader--, so it was a convenience picking. Furthermore, I'd never actually obtained it from using a trigonometry function but rather from a dot product. I merely named it "cos_view_to_normal" because that's what the meaning of it was. Take a look at the current shaders; I've been doing a bit of cleaning up and commenting --not fully yet, maybe 50%, but it should give you a rough idea where things are getting computed and how much is being done, per vertex and per pixel.
http://www.deeplayer.com/dan_w/goodies/ ... nimal.vert
http://www.deeplayer.com/dan_w/goodies/ ... nimal.frag
MamiyaOtaru wrote: He wasn't only talking about the atmosphere visible on the horizon, but the bluish tinge given by the atmosphere to everything underneath it. Not only ocean, but land looks quite bluish as well. Just as looking up at space through the atmosphere makes it look blue, looking down at the planet through the atmosphere makes everything a bit more blue.
We don't live on "the blue and green planet" Wink I'd never thought about it before, but it makes sense. All the photos I can dig up show everything tinted blue. "Natural color" images made from various sensors aren't photographs, and tend to present the land as we would perceive it while up close, not how it looks filtered through the atmosphere..
Case well made. And my eyes do see what you see. Sometimes I argue for the sake of fomenting debate, in the hope we can all together make discoveries about what's going on *exactly*. In the particular case of atmospheric scattering I have more questions than answers, as well as technical hurdles to overcome:
The bluishness of the atmosphere is not due to the atmosphere "being" blue, or having a blue "tint", but rather due to random scattering of photons, which statistically tend to impact blue photons more often than red or green, because the shorter wavelengths come closer to the size of "air molecules". Now, having said that, it's not like the other colors are being lost, but rather that they keep going straight most of the time. So, if we look at the sky away from the sun, we see a lot of blue. If we look directly at the sun we see more yellow (red and green). Thus, things on the ground don't get more blue light than green or red, rather they get an overall white illumination, but which is blue-deficient in the direction of the sun, and blue-supplemented in all other directions; IOW: Directional yellow light, and blue ambient light, to put it in GL lingo.
Now, back to klauss's pic from NASA, let me put the link here again,
http://www.nasa.gov/multimedia/imagegal ... e_337.html
I'm sure the preponderance of blue comes from the atmosphere directly, rather than from things on the ground. If anything, things on the ground are probably red or yellow tinted, and we just wouldn't know it due to a flood of blue coming from the atmo itself. So much, in fact, that maybe it doesn't even matter, in this case, what tint the stuff on the ground has.
But in other cases it may matter. "Depth cueing" is a catch-all term, but one interesting technique I once saw published in Game Programmer was using filtering by mip-map biasing: The idea was to leave red and green colors sharp, un-filtered, for the whole scene, but to smudge blue with increasing distance. Thus, mountains in the distance would have sharp detail in red and green, but be blurred in blue.
The technique is expensive to use, but one can get pretty close to the same effect by simply fading out the blue component of distant objects, and then adding a bit of blue evenly on top of them, with an intensity that would hopefully compensate the total amount of blue that was removed in the first place. Not that this is what I was thinking of doing for rendering a planet, but I'm coming to my point:
My present thinking about all this blue stuff is, if the sun is behind the camera, and we're looking towards the horizon, it would seem to me from first principles that the ground should be tinted yellow or orange. Why? Because if you were at that spot in the ground and looking horizontally at me and the sun behind me, you'd see a lot of golden sunset colors. You'd still be getting blue scattered light from other directions, but your face would look orange-tinted, and from my perspective I'd see more of your face than of your back, so, to me, you'd look blue-deficient. But on the other hand, the atmosphere in front of you would add overwhelming amounts of blue light, because, with the sun behind me, the only light that could possibly be scattered so much as to make a U-turn would be the blue component. So, if I render you before I render the atmo, I'd make you look orange; and then I'd splash a bucket of atmo blue on top. The end result is the depth cueing technique mentioned previously. So, this should look good.
There are other situations that aren't so clear cut to me, though: Suppose I'm looking straight down to the planet to an area of penumbra, say with the sun on my left. Should stuff on the ground look blue or red tinted? It's getting reddish, direct light from the left, but blue, scattered light from all other directions. If I was using bump-mapping, the answer is obvious: I'd compute lighting using reddish light, then add blue ambient light. But I'm not using bump-mapping. Not yet, anyways. But even if I was, there's a technical hurdle I'm not sure how to overcome: The blue ambient component should apply specially to this penumbra area of the planet, and to a lesser extent perhaps to other illuminated areas; but it should NOT be there in the side of the planet that is in shadows. But how do I distinguish them? "Ambient light", by definition, applies to the whole scene. And if I try to multiply my ambient light term by the cos of the angle between the incident light and the ground, I will again have a result equivalent to a directional light. IOW, I'd have to multiply ambient light by a filtered average of cos angle of incidence over a large area.
Or I could pass two sets of normals from the vertex to the fragment shader: The true normals and the "average" normals, or sea-level pseudo-normals for ambient light modulation. But the problem is that I'm already maxed out in the number of "varyings" or variables that I can pass from the vertex to the fragment shader.
In fact, my problem is even more general: In the fragment shader I do not know what the angle between the light and view vectors is. I only know the cos of the view vector to the normal, the cos of the light vector to the normal, and the cos of the angle between the view vector and the light's reflection vector. So, I don't even know, for a pixel near the horizon, whether the sun is behind me, or on the other side of the planet, or shining on it orthogonally.
Halleck
Elite
Elite
Posts: 1832
Joined: Sat Jan 15, 2005 10:21 pm
Location: State of Denial
Contact:

Post by Halleck »

Here's a good reference picture:
Image
BIG.

Wouldn't use that as a color reference (it's a color-adjusted version of a famous apollo photo), but it shows cloud cover, atmosphere, specularity quite nicely.
Post Reply